//头组件
<template>
  <div style="display: flex; align-items: center; justify-content: space-between; height: 60px;">
    <span style="text-align: center;flex:1; font-size: 24px;">心理咨询信息发布与预约系统 管理员界面</span>
    <el-dropdown style="margin-right: 20px;">
      <span class="el-dropdown-link" style="cursor: pointer; display: flex; align-items: center;">
        <i class="el-icon-user-solid"></i>
        <span style="margin-left: 5px;">{{user.name}}</span>
      </span>
      <el-dropdown-menu slot="dropdown">
        <el-dropdown-item @click.native="toUser">个人中心</el-dropdown-item>
        <el-dropdown-item @click.native="logout">退出登录</el-dropdown-item>
      </el-dropdown-menu>
    </el-dropdown>
  </div>
</template>
<style>
</style>

<script>
export default {
  name: "HEader",
  data(){
    return{
      user:JSON.parse(sessionStorage.getItem("CurUser"))
    }
  },
  methods:{
    toUser(){
      console.log('个人中心')
      this.$router.push('/Home')
    },
    logout(){
      console.log('退出登录')
      this.$confirm('确定退出登录吗？', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.$message({
          type: 'success',
          message: '退出成功!'
        })
      this.$router.push('/')
      sessionStorage.clear()
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消退出'
        })
      })
      
    }
  },
  created(){
    this.$router.push("/Home")
  }
}
</script>